package com.example.chat.controller;

import com.example.chat.model.ImageUploadResp;
import com.example.chat.service.FileService;
import com.example.common.common.config.response.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/8/4 23:47
 **/
@RestController
@RequestMapping("/api/upload")
@RequiredArgsConstructor
public class FileUploadController {
    private final FileService fileService;

    @PostMapping("/file")
    public Response<String> uploadFile(@RequestParam("file")MultipartFile file) {
        return Response.success(fileService.uploadFile(file));
    }

    @PostMapping("/image")
    public ImageUploadResp uploadImage(@RequestParam("file")MultipartFile file) {
        return fileService.uploadImage(file);
    }
}
